package com.tangyuan.video.task;


import com.tangyuan.feignapis.user.IUserFeignClient;
import com.tangyuan.video.service.IVideoHotService;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class TimedTask {

    @Autowired
    IVideoHotService videoHotService;
    @Autowired
    private IUserFeignClient userFeignClient;

    /**
     * 机器人浏览视频点赞
     *
     * @return
     */
    @XxlJob("robotLike")
    public void robotLike() {
        String param = XxlJobHelper.getJobParam();
        long millis = System.currentTimeMillis();
        videoHotService.robotHotLike(param);
        long millis2 = System.currentTimeMillis();
        System.err.println("本次执行耗时：" + (millis2 - millis));
    }

    /**
     * 机器人浏览视频点赞
     *
     * @return
     */
    @XxlJob("robotComment")
    public void robotComment() {
        String param = XxlJobHelper.getJobParam();
        videoHotService.robotComment(param);
    }

    /**
     * 机器人浏览视频点赞
     *
     * @return
     */
    @XxlJob("saveRobotNum")
    public void saveRobotNum() {
        String param = XxlJobHelper.getJobParam();
        userFeignClient.saveRobotNum(param);
    }

}
